/*
 * ServerNode.h
 *
 *  Created on: Apr 22, 2013
 *      Author: root
 */

#ifndef SERVERNODE_H_
#define SERVERNODE_H_

#include "CdnArea.h"
/*
 * cdn server node
 */
class CdnServerNode:public CdnArea{
public:
	CdnServerNode();
	virtual ~CdnServerNode();
	int ApendChildToLast(CdnArea * pNode);

	/**
	 * Update  cdn sever Node config Info
	 */
	int UpdateSvrNodeInfo(const char * pname,
			int ntype,
			int ispid,
			int svrflag,
			int svrmaxconnectcount,
			const char * wanlp,
			const char *lanip);

	/*
	 * Update  cdn sever Node run  Info by heatbeat notice
	 */
	int CdnNodeHeartBeatUpdate(const char * data,int flag);

	/*
	 * node properties
	 */
	int GetNodeType();
	int GetIsp();
	int GetServiceFlag();
	int GetStatus();
	int GetCpuUse();
	int GetMemoryUse();
	int GetMaxConnectCount();
	int GetCurrentConnectCount();
	uint32_t GetWanIpAddress();
	uint32_t GetLanIpAddress();
	uint64_t GetDiskTotalSpace();
	uint64_t GetDiskFreeSpace();
	uint64_t GetSendBandWidth();
	uint64_t GetRecvBandWidth();
	time_t	 GetLastHeartBeatTime();
	time_t	 GetLastDataSyncTime();

public:
	/*
	 * hash table
	 * link list
	 * */
	char  key[GUID_LEN];
	long  key_index;/*object hash key*/
	CdnServerNode * next;
	CdnServerNode * prev;
	CdnServerNode * hash_prev;
	CdnServerNode * hash_next;

private:
	int      nodetype;
	int  	 isp;
	int 	 service_flag;
	int      status;
	int 	 cpu_use;
	int 	 memory_use;
	int      max_connect_count;
	int      current_connect_count;
	time_t   last_heart_beat_time;
	time_t   last_data_sync_time;
	uint32_t wan_ip;
	uint32_t lan_ip;
	uint64_t total_disk_space;
	uint64_t free_disk_space;
	uint64_t send_band_width;
	uint64_t recv_band_width;
};

#endif /* SERVERNODE_H_ */
